package com.leshua.channel.mpos.service.lepos.impl;

import com.leshua.channel.mpos.mapper.lepos.MerchantMapper;
import com.leshua.channel.mpos.model.lepos.Merchant;
import com.leshua.channel.mpos.model.lepos.MerchantExample;
import com.leshua.channel.mpos.service.lepos.MerchantService;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author devlin
 * @version 1.0
 * @date 2020/4/24 12:08
 */
@Service
public class MerchantServiceImpl implements MerchantService {

    @Resource
    private MerchantMapper merchantMapper;

    @Override
    public Merchant queryMerchant(String merchantId) {
        MerchantExample example = new MerchantExample();
        MerchantExample.Criteria criteria = example.createCriteria();
        criteria.andMerchantIdEqualTo(merchantId);
        List<Merchant> merchantList = merchantMapper.selectByExample(example);
        return CollectionUtils.isEmpty(merchantList) ? null : merchantList.get(0);
    }
}
